package com.eduask.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.eduask.beans.Manager;
import com.eduask.dao.ManagerDAO;
import com.eduask.util.HibernateUtil;

@Repository
public class ManagerDAOImpl extends HibernateUtil implements ManagerDAO{

	@Override
	public Manager findManagerById(Integer id) {
		return getSession().get(Manager.class, id);
	}

	@Override
	public List<Manager> findAllManagers() {
		String hql = "from Manager manager order by manager.id asc";
		return getSession().createQuery(hql).list();
	}

	@Override
	public List<Manager> login(String name, String password){
		String hql = "from Manager manager where manager.name= ? and manager.password= ?";
		Query query = getSession().createQuery(hql);
		query.setParameter(0, name);
		query.setParameter(1, password);
		return query.list();
	}

}
